package com.kiloai.base.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

/**
 * Created by david on 2018/4/17.
 */

public class MathUtil {

    //去除double尾巴的0
    public static BigDecimal stripTrailingZeros(double d) {
        return new BigDecimal(d).stripTrailingZeros();
    }

    public static String stripTrailingTwo(double d){
        if(d == 0){
            return "0";
        }
        return new DecimalFormat("#.00").format(d);
    }
}
